import axios from '@/plugins/axios';
const BASE_API = import.meta.env.VITE_APP_BASE_APIURL as string;

import { CommonStore } from '@/store';
import { CommontTypes, ResponseVo, UserTypes } from '@/type';

export namespace UserService {
  export const pageUser = async (data:UserTypes.PageUserType & CommontTypes.IPaginationParam): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/user/page',{params:data, baseURL: BASE_API});
    return res;
  };

  export const addUser = async (data:UserTypes.IUserItem): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/user/add',data,{baseURL: BASE_API});
    return res;
  };

  export const editUser = async (data:UserTypes.IUserItem): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/user/edit',data,{baseURL: BASE_API});
    return res;
  };

  export const resetPassword = async (data:any): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/user/resetPassword',data,{baseURL: BASE_API});
    return res;
  };
  
  
  export const initPassword = async (data:any): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/user/initPassword',{params:data,baseURL: BASE_API});
    return res;
  };

  export const detailUser = async (id:number): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/user/detail',{params:{id}, baseURL: BASE_API});
    return res;
  };

  export const memberList = async (mobile:string): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/wxuser/list',{params:{mobile}, baseURL: BASE_API});
    return res;
  };
}
